ass Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        vector<int> test(nums);
        vector<int> ret;
        sort(test.begin(),test.end());
        int left = 0;
        int right = test.size()-1;
        int add = test[left]+test[right];
        while(add!=target)
        {
            add = test[left]+test[right];
            if(add>target)
            {
                right--;
            }
            else if(add<target)
            {
                left++;
            }
            else
            {
                break;
            }
        }
        int find1 = test[left];
        int find2 = test[right];
        auto it1 = std::find(nums.begin(),nums.end(),find1);
        auto it2 = std::find(nums.begin(),nums.end(),find2);
        if(it1 == it2)
        {
            it2 = std::find(it1+1,nums.end(),find2);
        }
        ret.push_back(it1-nums.begin());
        ret.push_back(it2-nums.begin());
        return ret;
    }
};

ass Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        unordered_map<string,vector<string>> mp;
        for(auto &str:strs)
        {
            string tmp(str);
            sort(tmp.begin(),tmp.end());
            mp[tmp].push_back(str);
        }
        vector<vector<string>> ret;
        for(auto it=mp.begin();it!=mp.end();it++)
        {
            ret.push_back(it->second);
        }
        return ret;
    }
};

class Solution {
public:
    int longestConsecutive(vector<int>& nums) {
        if(nums.size()==0)
        return 0;
        set<int> u_set;
        for (auto& e : nums) {
            u_set.insert(e);
        }
        int cur_sum = 1;
        int max_sum = 1;
        int val = *(u_set.begin());//1   1 2 3 4 100 200
        for (auto it = u_set.begin()++; it != u_set.end(); it++) {
            if (*it == (val + 1))
            {
                cur_sum++;
                val = *it;
                if (cur_sum > max_sum)
                {
                    max_sum = cur_sum;
                }
            }
            else
            {
                if (cur_sum > max_sum)
                {
                    max_sum = cur_sum;
                }
                cur_sum = 1;
                val = *it;
            }
        }
        cout << max_sum;
        return max_sum;
    }
};

class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int n= nums.size(),left = 0,right = 0;
        while(right<n){
            if(nums[right]!=0){
                swap(nums[left],nums[right]);
                left++;
            }
            right++;
        }
    }
};


class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0,right = height.size()-1,ret = 0;
        ret = min(height[left],height[right])*(right-left);
        while(left<right){
            if(height[left]<=height[right])
            {
                left++;
            }
            else
            {
                right--;
            }
            if(ret<min(height[left],height[right])*(right-left))
            ret = min(height[left],height[right])*(right-left);
        }
        return ret;
    }
};<Paste>
